﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp0
{
    public partial class ke1_ren : Form
    {
        string id;
        public ke1_ren()
        {
            InitializeComponent();
        }
        public ke1_ren(string myid)
        {
            this.id = myid;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = $"update Customer set Cname='{textBox2.Text}',Cphone='{textBox3.Text}',Cpassword='{textBox4.Text}'where Cid='{id}'";
            Dao dao = new Dao();
            int n = dao.Execute(sql);
         
            if (n > 0)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }
        public void data()
        {
            string sql = $"select * from Customer where Cid='{id}'";
            Dao dao = new Dao();
          
            IDataReader dr = dao.read(sql);
            while (dr.Read())
            {
                textBox2.Text = dr["Cname"].ToString();
                textBox3.Text = dr["Cphone"].ToString();
                textBox4.Text = dr["Cpassword"].ToString();
              
            }
           
        }

        private void ke1_ren_Load(object sender, EventArgs e)
        {
            label5.Text = id;
            data();
        }
    }
}
